
var timer = 3000;	
var turnImg = setInterval("scrollImg('.advertise ul li[class=cur]','.advertise ul li','.adimg')",5000)


function scrollImg(indexs,liElem,boxElem){
		var indexElem=$(indexs).index();
		indexElem = indexElem +1;
		console.log(indexElem);
		
		if(indexElem>=($(liElem).length)){
				indexElem = 0;
				$(liElem).eq(indexElem).addClass("cur").siblings().removeClass("cur");
				//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
				//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
				$(boxElem).eq(indexElem).animate({ 
								opacity: 1.0,
								zIndex:3
						},1000).siblings(boxElem).animate({ 
								opacity: 0.0,
								zIndex:2
						},1000)
				
			}else{
				
				 $(liElem).eq(indexElem).addClass("cur").siblings().removeClass("cur");
				//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
				//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
				$(boxElem).eq(indexElem).animate({ 
								opacity: 1.0,
								zIndex:3
						},1000).siblings(boxElem).animate({ 
								opacity: 0.0,
								zIndex:2
						},1000)
				
				}
		
	}
	



//back to top
/*(function() {
    var     $backToTopEle = $('.backToTop').click(function() {
            $("html, body").animate({ scrollTop: 0 }, 120);
    }), $backToTopFun = function() {
        var st = $(document).scrollTop(), winh = $(window).height();
        (st > 0)? $backToTopEle.show(): $backToTopEle.hide();    
        //IE6下的定位
        if (!window.XMLHttpRequest) {
            $backToTopEle.css("top", st + winh - 166);    
        }
    };
    $(window).bind("scroll", $backToTopFun);
    $(function() { $backToTopFun(); });
})();
*/


//返回顶部	
	$(function(){
   $(window).scroll(function () {
   
     if($(window).scrollTop() >= 400)//距离顶部多少高度显示按钮
     {
     $('.backtop').show();
     }else
     {
     $('.backtop').hide();
     }
   }); 
     
   $('#backTop').click(function(){
    $('body,html').animate({scrollTop:0},1000)
   });
   
   //按钮定位
   var win_width= $(window).width();      //窗口宽度
   var content_width= $('.wrap').width();     //容器宽度
   var topbtn_width= $('#backTop').width(); //按钮宽度
   //alert([win_width - content_width]/2);
   
//距离主体部分的右侧距离
   var topbtn_posi = ([win_width - content_width ]/2 - topbtn_width);
   $('#backTop').css({'right':topbtn_posi});
   
 })


$(function(){
		 $(".novel li:odd").css({background:'#fff'});
		 
		 $(".next").hover(function(){
			 clearInterval(turnImg);
			 
			 },function(){
			 turnImg = setInterval("scrollImg('.advertise ul li[class=cur]','.advertise ul li','.adimg')",5000) 
			}).click(function(){
			 		  var indexElem=$('.advertise ul li[class=cur]').index();//,'.advertise ul li','.adimg'
					  indexElem = indexElem +1;
					  if(!$('.adimg').is(':animated')){
					  if(indexElem>=($('.advertise ul li').length)){
					  indexElem = 0;
					  $(".advertise ul li").eq(indexElem).addClass("cur").siblings().removeClass("cur");
						//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
						//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
						$('.adimg').eq(indexElem).animate({ 
										opacity: 1.0,
										zIndex:3
								},1000).siblings('.adimg').animate({ 
										opacity: 0.0,
										zIndex:2
								},1000)
					  }else{
					  
					  	$(".advertise ul li").eq(indexElem).addClass("cur").siblings().removeClass("cur");
						//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
						//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
						$('.adimg').eq(indexElem).animate({ 
										opacity: 1.0,
										zIndex:3
								},1000).siblings('.adimg').animate({ 
										opacity: 0.0,
										zIndex:2
								},1000)
					  }
					  }
					  
			 })
		 $(".prev").hover(function(){
			 clearInterval(turnImg);
			 },function(){
			 turnImg = setInterval("scrollImg('.advertise ul li[class=cur]','.advertise ul li','.adimg')",5000) 
			}).click(function(){
			 		  var indexElem=$('.advertise ul li[class=cur]').index();//,'.advertise ul li','.adimg'
					  indexElem = indexElem -1;
					  if(!$('.adimg').is(':animated')){
					  if(indexElem<0){
					  indexElem =$('.advertise ul li').length-1;
					  $(".advertise ul li").eq(indexElem).addClass("cur").siblings().removeClass("cur");
						//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
						//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
						$('.adimg').eq(indexElem).animate({ 
										opacity: 1.0,
										zIndex:3
								},1000).siblings('.adimg').animate({ 
										opacity: 0.0,
										zIndex:2
								},1000)
					  }else{
					  
					  	$(".advertise ul li").eq(indexElem).addClass("cur").siblings().removeClass("cur");
						//$(boxElem).css({background:'url(images/pic'+indexElem+'.png) no-repeat'})
						//$(boxElem).animate({backgroundPosition:'50% 0%'},5000)
						$('.adimg').eq(indexElem).animate({ 
										opacity: 1.0,
										zIndex:3
								},1000).siblings('.adimg').animate({ 
										opacity: 0.0,
										zIndex:2
								},1000)
					  }
					  }
					  
			 })
	})


